import service from '@/utils/request'
import qs from 'qs'

export function get(url: string, params?: any, config?: any) {
  return service.get(url, {
    params,
    paramsSerializer: (params) => {
      return qs.stringify(params, { indices: false })
    },
    ...config,
  })
}

export function restGet(url: string, config?: any) {
    return service.get(url, config)
}

export function post(url: string, data: any, config?: any) {
  return service.post(url, data, config)
}

export function postForm(url: string, data: any, config?: any) {
  return service.post(url, qs.stringify(data, { indices: false }), {
    headers: { 'content-type': 'application/x-www-form-urlencoded' },
    ...config,
  })
}

export function put(url: string, data: any, config?: any) {
  return service.put(url, data, config)
}

export function remove(url: string, config?: any) {
  return service.delete(url, config)
}
